home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byte0487.arc / TELLO.ARC / DIV.LSP < prev    next >
Text File  |  1980-01-01  |  1KB  |  42 lines

  1. ; DIV2
  2. ; Dividing by 2 using lists of n ()'s
  3.  
  4. (defun create-n (n)
  5.        (do ((n n (1- n))
  6.         (a () (push () a)))
  7.        ((= n 0) a)))
  8.  
  9. (defvar div2-l )
  10. (setq div2-l (create-n 200.))
  11.  
  12. (defun iterative-div2 (l)
  13.   (do ((l l (cddr l))
  14.        (a () (push (car l) a)))
  15.       ((null l) a)))
  16.  
  17. (defun recursive-div2 (l)
  18.   (cond ((null l) ())
  19.     (t (cons (car l) (recursive-div2 (cddr l))))))
  20.  
  21. (defun iterative-div2-test (l)
  22.        (do ((i 300. (1- i)))
  23.        ((= i 0))
  24.        (iterative-div2 l)
  25.        (iterative-div2 l)
  26.        (iterative-div2 l)
  27.        (iterative-div2 l)))
  28.  
  29. (defun recursive-div2-test (l)
  30.        (do ((i 300. (1- i)))
  31.        ((= i 0))
  32.        (recursive-div2 l)
  33.        (recursive-div2 l)
  34.        (recursive-div2 l)
  35.        (recursive-div2 l)))
  36.  
  37. (define-timer div2-1 "Div2, Iterative" (iterative-div2-test div2-l))
  38. (qa-attempt "Div2, Iterative" (iterative-div2-test div2-l) nil)
  39.  
  40. (define-timer div2-2 "Div2, Recursive" (recursive-div2-test div2-l))
  41. (qa-attempt "Div2, Recursive" (recursive-div2-test div2-l) nil)
  42.